//window.onload = function (){
$(document).ready(function(){  
/*star start*/
		var oStar = document.getElementById("star");
		var aLi = oStar.getElementsByTagName("li");
		var oUl = oStar.getElementsByTagName("ul")[0];
		var oSpan = oStar.getElementsByTagName("span")[0];
		var oP = oStar.getElementsByTagName("p")[0];
		var i = iScore = iStar = 0;
		var aMsg = [
					"很容易|非常容易",
					"容易|容易",
					"一般|难易程度一般",
					"有点难|有点难",
					"非常难|非常难"
					]
		
		for (i = 1; i <= aLi.length; i++){
			aLi[i - 1].index = i;
			
			//鼠标移过显示分数
			aLi[i - 1].onmouseover = function (){
				fnPoint(this.index);
				//浮动层显示
				oP.style.display = "block";
				//计算浮动层位置
				oP.style.left = oUl.offsetLeft + this.index * this.offsetWidth - 104 + "px";
				//匹配浮动层文字内容
				oP.innerHTML = "<em><b>" + this.index + "</b> 星 " + aMsg[this.index - 1].match(/(.+)\|/)[1] + "</em>" + aMsg[this.index - 1].match(/\|(.+)/)[1];
			};
			
			//鼠标离开后恢复上次评分
			aLi[i - 1].onmouseout = function (){
				fnPoint();
				//关闭浮动层
				oP.style.display = "none";
			};
			
			//点击后进行评分处理
			aLi[i - 1].onclick = function (){
				iStar = this.index;
				oP.style.display = "none";
				oSpan.innerHTML = "<strong>" + (this.index) + " 星</strong> (" + aMsg[this.index - 1].match(/\|(.+)/)[1] + ")";
				//alert(iStar); //这里取值并在提交的时候插入数据库
			}
		}
		//评分处理
		function fnPoint(iArg){
			//分数赋值
			iScore = iArg || iStar;
			for (i = 0; i < aLi.length; i++) aLi[i].className = i < iScore ? "on" : "";	
		}
/*star end*/
//		alert($("#id").val());
		var id = $("#id").val();
		var path = "../SelCourse.action";
		$.ajax({
		      type: "post",
		      url: path,
		      cache: false,
		      dataType: "json",
		      data: "id="+id,
		      success: function(result){
		    	  $("#ms").html("已新增<font color=red>"+result[0].claCount+"</font>次课！");
		      }
		});
		
//};  //window.onload
});   //$(document).ready
